
*********************************************************************************
*This file analyzes Bank LPI versus LCR and QE
*********************************************************************************

***********************************************************************************
*LCR 
***********************************************************************************
cd ".."


use "data_intermediate/bank_ltisample_haircutrobust_new.dta", clear

merge m:1 rssd  using "data_input/lcrid.dta"

drop if _merge==2
replace lcrbig=0 if lcrbig==.
replace lcrmedium=0 if lcrmedium==.
replace lcrbig=2 if lcrmedium==1
drop _merge 


collapse (median) median=expected_lti, by (tq year quarter lcrbig)

drop if quarter==.

sort lcrbig tq

by lcrbig: gen normmedian=median/median[1]

line normmedian tq if lcrbig==0 || line normmedian  tq if lcrbig==1 || line normmedian  tq if lcrbig==2 ||, ylabel(,nogrid) xtitle("") ytitle("Liquidity Provision Index (normalized)") legend(label(1 "< 50 Billion") label(2 "> 250 Billion") label(3 "50 - 250 Billion") region(col(white))) bgcolor(white)  graphregion(color(white)) 
graph export "output/lpilcr.pdf", replace


***********************************************************************************
*QE 
***********************************************************************************

use "data_intermediate/bank_ltisample_haircutrobust_new.dta", clear

merge 1:1 year quarter rssd  using  "data_input/bankassetsliab.dta"

drop if _merge!=3
drop _merge 

gen postres=cash/assets if year==2014 & quarter==3
gen preres=cash/assets if year==2011 & quarter==1


sort rssd postres
by rssd: replace postres=postres[1]

sort rssd preres
by rssd: replace preres=preres[1]


drop if preres==.
drop if postres==.

gen reschange=(postres-preres)/preres
xtile quart=reschange if year==2011 & quarter==1, nq(4)


sort rssd quart
by rssd: replace quart=quart[1]

keep rssd  expected_lti quart quarter tq year 

collapse  (median) median=expected_lti, by (tq year quarter quart)

merge m:1 year quarter using "data_input/reserves.dta"

replace reserves=reserves/1000000

drop if quart==.
sort quart tq

by quart: gen mediannorm=median/median[1]

line mediannorm tq if quart==1 || line mediannorm tq if quart==2 || line mediannorm tq if quart==3 ||line mediannorm tq if quart==4 || line reserves tq if quart==1, yaxis(2) ||, ytitle("Liquidity Provision Index (normalized)") ylabel(, nogrid) ytitle("Excess Reserves (Trillion)", axis(2)) xtitle("") legend(label(1 "1st Quartile") label(2 "2nd Quartile") label(3 "3rd Quartile") label(4 "4th Quartile") label(5 "Excess Reserves") region(col(white))) bgcolor(white)  graphregion(color(white)) 
graph export "output/lpiqe.pdf", replace



